<template>
	<view class="home">
		<view class="banner" :style="[
        { backgroundPositionX: current * -20 + 'rpx' },
        { backgroundImage: 'url(/static/image/banner.jpg)' },
      ]">
			<u-swiper :list="banner" @change="change" height="400rpx"></u-swiper>
		</view>
		<scroll-view scroll-x class="scroll">
			<view class="item mr20" v-for="(item, index) in banner" :key="index">
				<image src="@/static/image/splash.jpg" mode="aspectFill" class="ww100 hh100"></image>
			</view>
		</scroll-view>
		<view class="d-s-c pl20 pt40 pr20 pb40">
			<view class="picker" @click="setPopup('showType',true)">
				<view class="d-c-c">
					<text class="mr10">类型</text>
					<u-icon name="arrow-down" size="12" color="#000"></u-icon>
				</view>
			</view>
			<view class="picker" @click="setPopup('showTime',true)">
				<view class="d-c-c">
					<text class="mr10">时间</text>
					<u-icon name="arrow-down" size="12" color="#000"></u-icon>
				</view>
			</view>
		</view>
		<view class="newTitle d-s-c pl20 mt40">
			<view class="name mr20">最新活动</view>
			<view class="sub">/Upcoming Events</view>
		</view>
		<!-- <u-skeleton rows="30" title loading v-if='firstload'></u-skeleton> -->
		<view class="newList">
			<list :list="list" :status="status"></list>
		</view>

		<tabbar></tabbar>
		<u-popup :show="showType" round='20rpx' @close="setPopup('showType',false)">
			<view class="type_popup bg-white br20">
				<view class="title line tc pb30">活动类型</view>
				<scroll-view scroll-y class="scrolls line mb30 ">
					<u-gap height="30rpx"></u-gap>
					<view class="d-s-s d-c">
						<view class="item " :class="item.checked&&'active'" v-for="(item,index) in typeList"
							:key="index" @click="setCheck(index)">
							{{item.name}}
						</view>
					</view>
					<u-gap height="30rpx"></u-gap>
				</scroll-view>
				<u-button text="确定" color="#1f083c" @click="setPopup('showType',false)"></u-button>
			</view>
		</u-popup>

		<u-popup :show="showTime" round='20rpx' @close="setPopup('showTime',false)">
			<view class="time_popup bg-white br20">
				<view class="title line tc pb30">选择时间</view>
				<scroll-view scroll-y class="scrolls line mb30 ">
					<u-gap height="30rpx"></u-gap>
					<view class="item" :class="active==index&&'active'" v-for="(item,index) in timeList" :key="index"
						@click="setAct(index)">
						{{item.name}}
					</view>
					<u-gap height="30rpx"></u-gap>
				</scroll-view>
				<u-button text="确定" color="#1f083c" @click="setPopup('showTime',false)"></u-button>
			</view>
		</u-popup>

	</view>
</template>

<script>
	import tabbar from "@/components/tabbar.vue";
	import list from "@/components/list.vue";
	export default {
		components: {
			tabbar,
			list
		},
		data() {
			return {
				firstload: true,
				status: 'nomore',
				list: [{
					name: "9-10月环境式驻场演唱会音乐剧阿米娅",
					urls: [],
					date: 'THU,SEP 04 - WED,OCT 08',
					address: '阿波罗尼亚 广州馆',
					status_name: '报名中',
					status: 1,
					fav: 0,
					tags: ['音乐/演出live', '戏剧']
				}, {
					name: "9-10月环境式驻场演唱会音乐剧阿米娅",
					urls: [
						'https://uviewui.com/album/1.jpg',
						'https://uviewui.com/album/2.jpg',
						'https://uviewui.com/album/3.jpg',
						'https://uviewui.com/album/4.jpg',
						'https://uviewui.com/album/7.jpg',
						'https://uviewui.com/album/6.jpg',
						'https://uviewui.com/album/5.jpg'
					],
					max: 7,
					date: 'THU,SEP 04 - WED,OCT 08',
					address: '阿波罗尼亚 广州馆',
					status_name: '已满员',
					status: 2,
					fav: 0,
					tags: ['音乐/演出live', '戏剧']
				}],
				banner: [
					"/static/image/tabbar_index.png",
					"/static/image/tabbar_index.png",
					"/static/image/tabbar_index.png",
				],
				current: 0,
				typeList: [
					{ name: '生活 Home&Lifestyle', checked: false },
					{ name: '艺术文化 Arts&Culture', checked: false },
					{ name: '饮食 Food&Drink', checked: false },
					{ name: '户外旅行 Outdoor&travel', checked: false },
					{ name: '身心健康 Mind&body', checked: false },
					{ name: 'MBTI Personalities', checked: false },
					{ name: '公益社会 Charities&Causes', checked: false },
					{ name: '个人与职业成长 Personal&Professional Growth', checked: false }
				],
				timeList: [
					{ name: '全部时间', key: 0 },
					{ name: '三日内', key: 1 },
					{ name: '一周内', key: 2 },
					{ name: '一月内', key: 3 }
				],
				active: 0,
				showType: false,
				showTime: false

			};
		},
		onLoad() {
			// setInterval(() => {
			//   this.current = this.current + 1;
			// }, 1000);
		},
		methods: {
			setPopup(name, bool) {
				this[name] = bool
			},
			setCheck(i) {
				this.typeList[i].checked = !this.typeList[i].checked
			},
			setAct(i) {
				this.active = i
			},
			change({ current }) {
				this.current = current;
			},
		},
	};
</script>

<style scoped lang="scss">
	.newList {
		padding: 20rpx;
		margin-top: 40rpx;
	}

	.newTitle {
		.name {
			font-size: 36rpx;
			font-weight: bold;
			position: relative;
			width: 5em;
			text-align: center;
			z-index: 1;

			&::after {
				content: "";
				position: absolute;
				background-color: #20c8d7;
				height: 40%;
				width: 100%;
				bottom: 0;
				left: 0;
				z-index: -1;
			}
		}

		.sub {
			font-size: 26rpx;
			color: #ccc;
		}
	}

	.time_popup {
		padding: 40rpx;

		.title {
			font-size: 30rpx;
			font-weight: bold;
		}

		.scrolls {
			height: 500rpx;


			.item {
				display: block;
				// background-color: #f8f7fa;
				padding: 30rpx 30rpx;
				margin-bottom: 20rpx;
				font-size: 26rpx;
			}

			.active {
				background-color: #f8f7fa;
				// color: #e68670;
			}

		}
	}

	.type_popup {
		padding: 40rpx;

		.title {
			font-size: 30rpx;
			font-weight: bold;
		}

		.scrolls {
			height: 500rpx;


			.item {
				// display: block;
				background-color: #f8f7fa;
				padding: 10rpx 30rpx;
				display: inline-block;
				margin-bottom: 20rpx;
				font-size: 26rpx;
			}

			.active {
				background-color: #fbe9e5;
				color: #e68670;
			}

		}
	}

	.picker {
		background-color: #fff;
		padding: 12rpx 30rpx;
		border-radius: 30rpx;
		margin-right: 30rpx;
		font-size: 28rpx;
	}

	.home {
		min-height: 100vh;
		background-color: #f8f7fa;
	}

	.scroll {
		display: flex;
		white-space: nowrap;
		margin-top: -190rpx;

		.item {
			width: 300rpx;
			border-radius: 10rpx;
			height: 400rpx;
			display: inline-block;
			overflow: hidden;

			&:first-child {
				margin-left: 20rpx;
			}

			image {
				display: block;
			}
		}
	}

	::v-deep .banner {
		height: 600rpx;
		background-repeat: no-repeat;
		background-position-y: bottom;
		transition: 0.5s;
		// background-position:-20rpx bottom;
		background-size: 120%;

		.u-swiper {
			background-color: transparent !important;
		}
	}
</style>